package confidence.helpers;


public class SnapshotUbi extends Snapshot implements SnapshotAss {
	
	public boolean addTag (Tag pTag, String pLabel) {
		if (pLabel.equals (Status.getStringValue ("UBI_ANKLE_LEFT")) && Status.getTagStatus (Constants.ANKLE_LEFT)) {
			if (tags [Constants.ANKLE_LEFT] == null) {
				tags [Constants.ANKLE_LEFT] = pTag;
			} else {
				return false;
			}
		} else if (pLabel.equals (Status.getStringValue ("UBI_ANKLE_RIGHT")) && Status.getTagStatus (Constants.ANKLE_RIGHT)) {
			if (tags [Constants.ANKLE_RIGHT] == null) {
				tags [Constants.ANKLE_RIGHT] = pTag;
			} else {
				return false;
			}								
		} else if (pLabel.equals (Status.getStringValue ("UBI_WRIST_RIGHT")) && Status.getTagStatus (Constants.WRIST_RIGHT)) {
			if (tags [Constants.WRIST_RIGHT] == null) {
				tags [Constants.WRIST_RIGHT] = pTag;
			} else {
				return false;
			}
		} else if (pLabel.equals (Status.getStringValue ("UBI_CHEST")) && Status.getTagStatus (Constants.CHEST)) {
			if (tags [Constants.CHEST] == null) {
				tags [Constants.CHEST] = pTag;
			} else {
				return false;
			}
		} else if (pLabel.equals (Status.getStringValue ("UBI_BELT")) && Status.getTagStatus (Constants.BELT)) {
			if (tags [Constants.BELT] == null) {
				tags [Constants.BELT] = pTag;
			} else {
				return false;
			}
		}
		return true;
	}
	
	public void computeDT ()
	{
		long dateTime=0;
		int numTags=0;
		
		for(int i = 0; i < Status.getIntValue("TAG_COUNT"); i++){
			if(Status.tagsActive[i] && this.tags != null && this.tags[i] != null && this.tags[i].date != null){
				dateTime = dateTime + this.tags[i].date.getTime ();
				numTags++;
			}
		}
		if(numTags > 0)
			time = ((double) dateTime) / ((double) numTags);

	}
	
	public boolean isComplete () {
		for (int i = 0; i < Status.getIntValue ("TAG_COUNT"); i ++) {
			if (Status.getTagStatus (i) && (tags [i] == null)) {
				return false;
			}
		}
		return true;
	}

	public void createMissingTags () {
		for (int i = 0; i < Status.getIntValue ("TAG_COUNT"); i ++) {
			if (tags [i] == null) {
				tags [i] = new Tag ();
			}
		}
	}

	@Override
	public void averageTags() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setAfterBreak() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setClass(String value) {
		trueClass = value;
		
	}
	
}
